﻿Public Class frmUnterschrift

    Private WithEvents Signature As New clsSignatureControl

    Private Sub frmUnterschrift_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
        Me.Text = clsGlobals.eOperation.ToString

        _Signature.Clear()

    End Sub

    Private Sub frmUnterschrift_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        e.Cancel = True
        cmdZurueck_Click(sender, e)
    End Sub

    Private Sub cmdZurueck_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdZurueck.Click
        clsGlobals.ShowForm(Me, frmHauptmenue)
    End Sub

    Private Sub SaveSign()

        Try
            If Not _Signature.Lines.Count > 0 Then Throw New Exception("Bitte unterschreiben Sie zuerst !")

            If Not Signature.SaveSign("MySignFile.bmp") Then Throw New Exception("Die Unterschrift konnte nicht gespeichert werden !")

            Dim PTS As New PaketTrackerService.Webservices
            PTS.Ausgeliefert(clsData.szPaketIdent, clsData.Mitarbeiter.Guid, clsData.gdFahrzeug, "Paket-Abgabe")

            MsgBox("Daten gespeichert!", MsgBoxStyle.Information)

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation)
        End Try

    End Sub

    Private Sub frmUnterschrift_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Disposed
        If Not Signature Is Nothing Then
            Signature.Dispose()
            Signature = Nothing
        End If
    End Sub

    Private Sub frmUnterschrift_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        _Signature.Location = Me.Location
        _Signature.Width = Me.Width
        _Signature.Height = Me.Height - cmdZurueck.Height
        _Signature.Visible = True
        Me.Controls.Add(_Signature)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SaveSign()
    End Sub
End Class